package com.focusai.efairy.ui.adapter;

import android.content.Context;

import com.focusai.efairy.R;
import com.focusai.efairy.model.project.ProjectItem;
import com.focusai.efairy.ui.adapter.base.BaseRecyclerAdapter;
import com.focusai.efairy.ui.adapter.base.BaseRecyclerViewHolder;

/**
 * Created by luo_guangwen on 2017/8/13.
 */

public class ProjectListAdapter extends BaseRecyclerAdapter<ProjectItem> {

    private int selectPosition = -1;

    public ProjectListAdapter(Context context) {
        super(context);
    }

    @Override
    protected int getItemLayoutId() {
        return R.layout.item_project_lis;
    }

    @Override
    protected void onBindBaseRecyclerViewHolder(BaseRecyclerViewHolder holder, int position) {
        ProjectItem item = mList.get(position);
        holder.setText(R.id.text_project_name, item.efairyproject_name);
        holder.setText(R.id.tv_project_adress, item.efairyproject_address);
        holder.setText(R.id.text_project_number, item.efairyproject_device_online_number + "/" + item.efairyproject_total_devices);
        holder.setText(R.id.text_project_user_number, item.efairyproject_total_users + item.efairyproject_total_gms + "");
        if (selectPosition >= 0 && selectPosition < mList.size() && selectPosition == position) {
            holder.getView(R.id.ll_root).setBackgroundColor(mContext.getResources().getColor(R.color.bg_gray));
        }else {
            holder.getView(R.id.ll_root).setBackgroundColor(mContext.getResources().getColor(R.color.white));
        }
    }

    public void setSelectPosition(int selectPosition) {
        this.selectPosition = selectPosition;
    }
}

